package org.hq.mysecurity.uitls;

//统一返回为结果集R   1为成功,0为失败
public class R<T>  {

    private Integer code; //编码：1成功，0和其它数字为失败
    private String msg; //错误信息
    private T data; //数据

    //静态方法返回成功时候,R的属性
    public static <T> R<T> success(T object) {
        R<T> r = new R<>();
        r.data = object;
        r.code = 1;
        return r;
    }

    //静态方法返回失败时传入消息
    public static <T> R error(String msg) {
        R r = new R();
        r.msg = msg;
        r.code = 0;
        return r;
    }
    // getter和setter方法省略...  
}